<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta
			name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no"
		/>
		<meta name="format-detection" content="telephone=yes" />
		<meta name="format-detection" content="email=no" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Cache-Control" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		<title>个人中心</title>
		<!-- 引入 vant UI 组件库样式文件 -->
		<link rel="stylesheet" href="../common/css/vant-index.css" />
		<link rel="stylesheet" href="css/patientStudio.css" />
		<style type="text/css">
			.van-cell__title{
				color: #3E3E3E;
				font-size: 14px;

			}
			.van-cell__value{
				color: #3E3E3E;
				font-size: 16px;
			}
			.van-button--info{
				background-color: #E22E30;
				border-color: #E22E30;
				font-size: 18px;
			}
			
		</style>
	</head>

	<body>
		<div id='app' v-cloak>
			<div class="id_background"></div>
			<div class="id_container">
				<div class="id_banner flex">
					<div class="id_banner_avater">
						<img v-if="detail.patientsImg" :src="detail.patientsImg"/>
						<img v-if="!detail.patientsImg" src="img/logo.png"/>
					</div>
					<div class="id_banner_right">
						<div class="flex id_banner_right_info">
							<span class="fontsize18 color51" style="margin-right:10px;">{{detail.patientsName}}</span>
							<span v-if="detail.age" style="margin: 0 10px;">{{detail.age}}岁</span>
							<img v-if="detail.patientsSex==1" src="img/follow/men.png"/>
							<img v-if="detail.patientsSex==2" src="img/follow/woman.png"/>
						</div>
						<p style="margin: 10px 0;">所在城市：{{detail.location}}</p>
						<p><van-icon name="phone-o" />{{detail.patientsMobile}}</p>
					</div>
				</div>
				<div class="link_wx" :style="{ display: wxshow }" id="launch-btn"></div>
				<div class="link_wx" :style="{ display: wxshow }" id="launch-btn1"></div>
				<div class="link_h5" :style="{ display: h5show }" @click="linkToToast">
					<img src="http://h5.test.dtx-tech.com/patient/img/wx_patient/link_wxindex.png"/>
					<img v-if="detail.buyPackage==0" src="http://h5.test.dtx-tech.com/patient/img/wx_patient/wx_service_1.png"/>
					<img v-if="detail.buyPackage==1" src="http://h5.test.dtx-tech.com/patient/img/wx_patient/wx_service_2.png"/>
				</div>
				<div class="doctor_left_title">
					<span class="doctor_left_title_border"></span>
					<span class="doctor_left_title_name">病情概况</span>
				</div>
				<div class="id_info">
					<van-cell-group>
						<van-cell>
							<template #title>
								<span class="custom-title"> 糖尿病诊断 </span>
							</template>
							<template #value>
								{{detail.patientsDiabetisDiagnoseText}}
							</template>
						</van-cell>
						<van-cell>
							<template #title>
								<span class="custom-title"> 糖尿病类型 </span>
							</template>
							<template #value>
								{{detail.patientsDiabetisTypeName}}
							</template>
						</van-cell>
						<van-cell v-if='detail.patientsConfirmedDate'>
							<template #title>
								<span class="custom-title"> 确诊日期 </span>
							</template>
							<template #value>
								{{detail.patientsConfirmedDate}}
							</template>
						</van-cell>
					</van-cell-group>
				</div>
				<div class="doctor_left_title" v-if="detail.patientsSymptoms">
					<span class="doctor_left_title_border"></span>
					<span class="doctor_left_title_name">病情描述</span>
				</div>
				<div class="doctor_box doctor_box_100" v-if="detail.patientsSymptoms">
					<p>{{detail.patientsSymptoms}}</p>
				</div>
				
				<div class="edit_info">
					<van-button round type="info" block @click='linkToEdit(detail.patientId)'>修改资料</van-button>
				</div>
			</div>
		</div>
	</body>
	<!-- 引入 rem -->
	<script src="../common/js/rem.js"></script>
	<!-- 上线环境用 -->
	<script src="../common/js/vue.global.prod.js"></script>
	<!-- 引入 UI 组件库 -->
	<script src="../common/js/vant.min.js"></script>
	<!-- axios 接口调用 -->
	<script src="../common/js/axios.min.js"></script>
	<script src="../common/js/url.min.js"></script>
	<script src="../base.js"></script>
	<script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
	<script type="module">
		import {
			getAction,
			postAction,
			spliceUrl,
		} from "../common/js/api/vue3-axios-utils.js";
	
		import { wechatInit,wx_launch,is_weixn } from './js/wechat1.js'

		const PatientData = {
			data() {
				return {
					url: {
						getDetail:'/patient/pa/get',
						wechatMini:'/sys/wechat/signature'
					},
					detail:{},
					id:'',
					wxshow:'none',
					h5show:'block'
				};
			},
			created() {
				this.init()
				wechatInit()
			},
			mounted() {
				
			   
			},
			methods: {
				async init () {
					this.id = url('?id')
	                await this.handleGetDetail()
	                if(is_weixn()){
	                		this.wxshow = 'block'
	                		this.h5show = 'none'
	                }else{
	                		this.wxshow = 'none'
	                		this.h5show = 'block'
	                }
	           	},
	           	
				handleGetDetail(){
					getAction(spliceUrl(this.url.getDetail),{patientId:this.id}).then((res) => {
						res = res.data
						console.log('handleGetDetail',res)
						if(res.success){
							this.detail = res.result
							this.weapp()
						}
					})
				},
				linkToEdit(id){
					window.location.href='editPatientInfo.html?id='+id
				},
				linkToToast(){
					this.$toast.fail('请使用微信打开')
				},
				weapp(){
					// 跳转小程序首页
				    let content = `
				      	<div class="indexbtn">
						    	<img src="http://h5.test.dtx-tech.com/patient/img/wx_patient/link_wxindex.png"/>
						</div>
				      <style>
				        .indexbtn img{ display: block; width: 100%; }
				      </style>
				      `;
				    let launchParams = {
				      eleId:"launch-btn", // 元素id
				      url: "pages/index/index.html", // 跳转小程序的页面路径
				      content:content, // 自定义的html内容
				      appid:'gh_1275768357c8'
				    };
				    wx_launch(launchParams);
				    
				    //跳转小程序服务详情
				    let content1;
				    if(this.detail.buyPackage=='0'){
				    		content1 = `
					      	<div class="indexbtn">
							    	<img src="http://h5.test.dtx-tech.com/patient/img/wx_patient/wx_service_1.png"/>
							</div>
					      <style>
					        .indexbtn img{ display: block; width: 100%; }
					      </style>
					      `;
				    } else{
					    	content1 = `
					      	<div class="indexbtn">
							    	<img src="http://h5.test.dtx-tech.com/patient/img/wx_patient/wx_service_2.png"/>
							</div>
					      <style>
					        .indexbtn img{ display: block; width: 100%; }
					      </style>
					     `;
				    }
				    let launchParams1 = { 
					    	eleId:"launch-btn1", // 元素id 
					    	url: "pages/serviceDetail/serviceDetail.html", // 跳转小程序的页面路径 
					    	content:content1, // 自定义的html内容 
					    	appid:'gh_1275768357c8' 
				    	}; 
				    	wx_launch(launchParams1);
				}
			},
			components:{
			}
		};

		const app = Vue.createApp(PatientData);

		app.use(vant);

		// 通过 CDN 引入时不会自动注册 Lazyload 组件
		// 可以通过下面的方式手动注册
		app.use(vant.Lazyload);

		// 调用函数组件，弹出一个 Toast
		// vant.Toast("刷新成功");

		app.mount("#app");
	</script>

</html>

